<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JSON</title>
    <script>
        function f1() {
            let user = {"id": 1, "userneme": "admin", "password": "123456"}
            console.log(user)
            console.log(user.id)
            console.log(user.password)
            // 中括号和.十合一替换使用的两者等效
            // 但是属性名如果数字开头只能中括号
            console.log(user["userneme"])
            console.log(user["password"])
        }

        function f2() {
            let address = {"province": "江苏", "city": "南京"}
            let user = {"id": 1, "username": "花东煜", "passwor": "123456", "address": address}
            console.log(user.address)
            console.log(user.address.city)
            console.log(user.id)
            console.log(user.address["province"])
        }

        function f3() {
            let users = [{
                "id": 1,
                "username": "花东煜",
                "password": "123456"
            }, {
                "id": 2,
                "username": "花南煜",
                "password": "123456"
            }, {
                "id": 3,
                "username": "花西煜",
                "password": "123456"
            }];
            console.log(users)
            console.log(users[0].username)
            console.log(users[1].password)
            console.log(users[2].id)
        }
    </script>
</head>
<body>
<button onclick="f1()">基本语法</button>
<br>
<button onclick="f2()">对象中包含对象</button>
<br>
<button onclick="f3()">对象数组</button>
<br>
</body>
</html>